from odoo import fields, models, api, _
from odoo.exceptions import UserError, ValidationError


class PlaceOrderWizard(models.TransientModel):
    _inherit = "place.order.wizard"

    def confirmation(self):
        """确认下单"""
        # 字段检查
        if self.mpn_id.s_disable_order:
            raise UserError(_(f"This product {self.mpn_id.name} is disabled for order. Please contact the engineer."))
        res = super(PlaceOrderWizard, self).confirmation()
        return res
